<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreatePayOrderTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('pay_order', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->integer('user_id')->default(0)->comment('支付用户ID');
            $table->string('order_id', 50)->default('')->comment('内部订单号');
            $table->string('out_trade_no', 50)->default('')->comment('第三方平台交易号');
            $table->integer('total_amount')->default(0)->comment('支付总金额（分）');
            $table->string('channel', 10)->default('')->comment('支付渠道：wechat-微信，alipay-支付宝');
            $table->tinyInteger('status')->default(1)->comment('0:待支付,1:支付成功,2:支付超时,3:支付失败');
            $table->timestamp('finished_at', 0)->nullable();
            $table->timestamps();
            $table->index('user_id', 'user_id');
            $table->index('order_id', 'order_id');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        // Schema::dropIfExists('pay_order');
    }
}
